Visual Studio program "VB2010 Gal MOND PP" - Description and operation

Introduction and Purpose

The purpose of the Visual Basic program "VB2010 Gal MOND" is to demonstrate galaxy simulation using MOND. The simulation uses Parallel Programming.
For a copy of "VB2010 Gal MOND PP.exe" select: VB2010 Gal MOND.zip.

This zip also contains the program: "VB2010 Gal MOND".
The emphasis in this document is about Parallel Programming.
For more general information about the program "VB2010 Gal MOND PP" select: VB2010 Gal MOND operation
The program "VB2010 Gal MOND" is based around the question: MOND - What is involved


Description

The Visual basic program program "VB2010 Gal MOND PP" consits of 4 Forms (or displays):


Operation - Control Form

Operation of the program is done from the Control Form.
Picture 1A
Specific in order to handle Parallel Programming the Control Display uses two parameters:N Proc and PP Trace. Also the parameter Target is new.
  • The parameter N Proc indicates the number of Processors to be used. Valid values are 0,1,2,3 and 4.
    When N Proc = 0 the concept of Parallel Programming is not used. The logic used is the same as in the program ""VB2010 Gal MOND"
    When N Proc = 1 the concept of Parallel Programming is used for one Processor. The difference between 0 and 1 gives an indication of the overhead that Parallel Programing introduces
    When N Proc = 4 the concept of Parallel Programming is used for four Processor's. This is the maximum of procesors supported.
  • The parameter PP Trace is used display intermediate program print data. The parameter can be set "On" or "Off".
    When PP Trace = "On" trace data is shown on the "Print Form". When PP Trace = "Off" the standard values are shown on the "Print Form".
  • The parameter Target shows the maximum number of iteration cycles.
    • When the value is zero the program stops only when the Stop Command is selected.
    • When the value is non zero the program stops after the number of program iteration cycles is reached
    In both cases the message "Continue ?" is displayed, together with the two commands: Yes or
    When Yes is selected the simulation continues.
    When No is selected the simulation finishes and a new simulation can start.


Display Form

The "Display Form" shows the result of the simulation.
Picture 2A
The Display form shows the following 4 parameters:
Time , Angle , Cycle and Display mode
  • The parameter Time shows the execution time in seconds.
  • The parameter angle shows the angle of rotation in degrees.
  • The parameter Cycle shows the actual number of iterations performed.
  • The parameter Display mode is shown in the top right corner. The standard value is 100.
    The parameter identifies the number of stars displayed.
    When "# ring" = 10 and "# star" = 50 and display mode = 1 than only star 1 is displayed
    When display mode = 2 than only star 1 and star 26 are displayed


Print Form

This Form shows the result of the simulation at the end of the "Mass Calculation" phase in six columns.
VB2010 Gal MOND
Picture 2C
Text

Monitor Form

Picture 4A
The Monitor Form shows for each of the 4 processors in use the following parameters:
State 1, State 2, sync (two values) and star cnt.
  • State 1 is the requested state by the master processor 1.
  • State 2 is the active state of the slave processor.
  • sync is the active state of program synchronisation.
  • star cnt The total number of star updates for each processor.
    For each cycle this number increases with ("n star" * "n ring" / np)


Program Evaluation

The following table shows the results of two different sets of tests: Because the number of cycles in the second set is only 50% of the first set, this increase is only a factor of 2.
test #ring # star MOND Target methode #pr = 0 #pr = 1#pr = 2 #pr = 3#pr = 4
1 10 50 Off 50 1 25.8 36.5 21.7 20.6 19.6
2 10 50 On 50 1 32.7 42.9 26.8 24.6 23.4
3 10 50 Off 20 2 79.3 88.2 56.1 55.8 51.7
4 10 50 On 20 2 88.4 97.6 61.7 59.5 56.9
5 20 50 Off 25 1 50.7 69.643.1 40.8 39.8
6 20 50 On 25 1 62.8 79.9 49,2 48,2 45.8
7 20 50 Off 10 2 156.3 175.7 109.9 105.9100.4
8 20 50 On 10 2 176.2 195121.3 119.9110.6

The same test on a Pentium P4

test #ring # star MOND Target methode #pr = 0 #pr = 1
1 10 50 Off 50 1 32.5 33.0
2 10 50 On 50 1 39.4 39.9
3 10 50 Off 20 2 87.2 89.4
4 10 50 On 20 2 100.8 100.5
5 20 50 Off 25 1 58.0 57.8
6 20 50 On 25 1 71.6 70.3
7 20 50 Off 10 2 158.3 163.0
8 20 50 On 10 2 184.5 184.9


Parallel Programming

1. Program Main

Program "Main" services as Processor 1 or the Master Processor to control Parallel Programming.
The program performs 3 specific tasks:
    Main  
     |--->MainPP
     |       |------Assign                       Backgroundworker1
     |
     |-----Proc2                                         |
     |       |---------------------StartSt-------------->|
     |       |<--------------------ActiveSt--------------|    
     |       |------Methode_2PP                          |---Methode_2PP
     |       |         |-------Synchronisation           |        |--Synchronistaion
     |       |<------------------FinishedSt--------------|    
     |                                                   |
     |-----Cancel                                        |  
     |       |--------------------CancelSt-------------->|
     |       |<--------------------EndSt-----------------|
     |  

    Master pp=1                                    Slave pp=2,3 and 4 

Subroutine MainPP

For a listing: VB2010 Gal MOND MainPP.vb
This subroutine is part of the Main program in Processor 1 or the Master Processor.
The most important function is a call to subroutine "Assign".

Subroutine Assign

For a listing: Assign
This subroutine assigns the Backgroundworker1, 2 or 3 based on the parameter: "N Proc". (Requested number)
At the end of the subroutine the parameter "np" (Active number) is set equal to "N Proc" (Requested number)

Subroutine Proc2

For a listing: Proc2
This subroutine is resident in Processor 1 or the Master Processor.
This subroutine performs the communication between the Master Processor and each of the Slave Processors.
In each of the Slave Processors this is the Backgroundworker (1,2 or 3)
Subroutine Proc2 performs one iteration of the Runga Kutta method. This functionality is performed by the subroutine Methode_2_PP(1)

There exist also a subroutine "Proc1" for Newton's Law

Subroutine Methode_2_PP

For a listing: Methode_2_PP
The subroutine requires one parameter: pnbr = processor number. This specific subroutine calculates one iteration cycle of the Runga Kutta method for any processor

The Runga Kutta consists of the calculation of 4 sets of 4 parameters:
(kax0,kay0,kbx0,kby0), (kax1,kay1,kbx1,kby1), (kax2,kay2,kbx2,kby2) and (kax3,kay3,kbx3,kby3)

Program Backgroundworker1

For a listing: Backgroundworker1
This specific program is resident in Processor 2.
There is a separate program "Backgroundworker2" resident in Processor 3
There is a separate program "Backgroundworker3" resident in Processor 4
The program "Backgroundworker1" communicates with the subroutine "Proc2" in Processor 1.

Subroutine Synchronisation

For a listing: Synchronisation
The subroutine "Synchronisation" requires two parameters: pnbr and stat

The subroutine "Synchronisation" uses two communication arrays: Sync0 and Sync1

Synchronisation now works as follow (We assume 4 prcessors are used):
  1. The first time each each processor receives a stat = 1 request and the parameter Sync1 is set equal to 1.
    All the 4 processors are in synchronisation when the total value of all Sync1 values is equal to 4.
  2. The second time each each processor receives a stat = 2 request and the parameter Sync0 is set equal to 2.
    All the 4 processors are in synchronisation when the total value of all Sync0 values is equal to 8.
  3. The third time each each processor receives a stat = 3 request and the parameter Sync1 is set equal to 3.
    All the 4 processors are in synchronisation when the total value of all Sync1 values is equal to 12.
  4. The fourth time each each processor receives a stat = 4 request and the parameter Sync0 is set equal to 4.
    All the 4 processors are in synchronisation when the total value of all Sync0 values is equal to 16.
The benefits of this communication protocol is that is individual processor independent. That means that when processor 1 has detected that all the processors are in state 1 (based on Sync1) it can immediate go to state 2 and set Sync0 equal to 2 and wait until all processors are in state 2.
For processor 2 this has no consequences. When processor 2 is slightly delayed it will detect later that all the processors are in state 1 and also later go to state 2 and set set Sync0 equal to 2
This symmetric communication protocol does not work if only one Sync array is used.

Subroutine Cancel

For a listing: Cancel
This program is resident in Processor 1.
The main task of the subroutine is to set the "CancelSt" request for all the processors 1 to 4.


Reflection 1


Feedback

None


Created 22 March 2016

Back to my home page: Contents of This Document